import 'package:flutter/material.dart';
import 'package:intl/intl.dart';

class SliderDemo extends StatefulWidget {
  const SliderDemo({super.key});

  @override
  State<SliderDemo> createState() => _SliderDemoState();
}

class _SliderDemoState extends State<SliderDemo> {
  double _sliderItemA = 0;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('SliderDemo'),
        elevation: 0.0,
      ),
      body: Container(
        padding: EdgeInsets.all(16.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text('value:$_sliderItemA'),
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Slider(value: _sliderItemA, onChanged: (value){
                  setState(() {
                    _sliderItemA = value;
                  });
                  
                },
                activeColor: Theme.of(context).accentColor,
                inactiveColor: Theme.of(context).accentColor.withOpacity(0.3),
                min: 0.0,
                max: 10.0, //默认1.0
                divisions: 10,
                label: '${_sliderItemA.toInt()}',)
              ],
            )
          ],
        ),
      ),
    );
  }
}